<template>
  <div>
    <!-- 新增修改表单 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="DialogFormVisibleCom" :close-on-click-modal="false" :close-on-press-escape="false">
      <el-form ref="dataForm" :rules="rules" :model="formSubmitDataCom" label-position="right" label-width="120px"
               style="width: 90%; margin:10px auto;">

        <el-row :gutter="20">
          <el-col :span="12">
            <!-- 所属法人 -->
            <el-form-item label="所属法人" prop="lp_code">
              <el-select v-model="formSubmitDataCom.lp_code" class="filter-item" placeholder="Please select"
                         v-bind:disabled="dialogStatus==='update'">
                <el-option v-for="item in lpOptions" :key="item.lp_code" :label="item.lp_name" :value="item.lp_code"/>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="12">
            <!-- 备注 -->
            <el-form-item label="解析编号" prop="alys_code">
              <el-input type="text" v-model="formSubmitDataCom.alys_code" placeholder="Please select" :disabled="true"></el-input>
            </el-form-item>
          </el-col>

           <el-col :span="24">
            <!-- 备注 -->
            <el-form-item label="解析描述" prop="alys_name">
              <el-input type="textarea" v-model="formSubmitDataCom.alys_name" placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="解析类型" prop="alys_type">
              <el-select v-model="formSubmitDataCom.alys_type" class="filter-item" placeholder="Please select"
                         >
                <el-option v-for="item in pgTypeOptions" :key="item.code" :label="item.name"
                           :value="item.code"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <!-- 备注 -->
            <el-form-item label="路径+程序名/代码描述" prop="pg_text">
              <el-input type="textarea" v-model="formSubmitDataCom.pg_text" placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>

        
          <el-col :span="24">
            <!-- 备注 -->
            <el-form-item label="备注：" prop="remark">
              <el-input type="textarea" v-model="formSubmitDataCom.remark" placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
        </el-row>


      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button @click="resetFormData">
          重置
        </el-button>
        <el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
          提交
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

import XEUtils from 'xe-utils'
import exctfqcoptions from '@/views/CurveManageNew/mixins/exctfqcoptions'
export default {
  name: 'submitForm',
  mixins:[exctfqcoptions],
  components: {
    //PageHeaderLayout,
  },
  props: {
    dialogFormVisible: {
      type: Boolean,
      default: false
    },
    dialogStatus: {
      type: String,
    },
    formSubmitData: {
      type: Object,
      default: function () {
        return {}
      }
    },
    // 法人selectData
    lpOptions: {
      type: Array
    },
    pgTypeOptions:{
      type: Array
    },
    baseCurveOptions: {
      type: Array
    }
  },


  // 定义属性
  data() {
  

    return {
      textMap: {
        update: '修改',
        create: '新增'
      },
      rules: {
        alys_code: [{required: true, message: '解析编号必填', trigger: 'change'}],
        alys_name: [{required: true, message: '解析描述必填', trigger: 'change'}],
        alys_type: [{required: true, message: '解析类型必填', trigger: 'change'}],
        pg_text: [{required: true, message: '路径+程序名/代码描述必填', trigger: 'change'}],
       lp_code: [{required: true, message: '所属法人必填', trigger: 'change'}],
       
      },
      // 表单用到的值
      // calendarTypeOptions,
      // statusOptions: ['published', 'draft', 'deleted'],
    }
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {
    DialogFormVisibleCom: {
      get() {
        return this.dialogFormVisible
      },
      set(val) {
        this.$emit('update:dialogFormVisible', val)
      }
    },
    formSubmitDataCom: {
      get() {
        return this.formSubmitData
      },
      set(val) {
        this.$emit('update:formSubmitData', val)
      }
    }
  },
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    resetFormData() {
      this.$emit('resetFormDataEmit')
    },
    /* 基础曲线值变化触发事件 */
    bsCvCodeChange(val) {
      this.$emit('bsCvCodeChangeEmit', val)
      console.log('ssss', val);
    },


    createData() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$emit('handleFromCreateDataEmit')

        }
      })
    },

    updateData() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$delete(this.formSubmitDataCom, "_XID");
          this.$delete(this.formSubmitDataCom, "cv_name");
          const tempData = Object.assign({}, this.formSubmitData)
          this.$emit('handleFromUpdateDataEmit')
        }
      })
    },

  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  beforeCreate() {
  }, // 生命周期 - 创建之前
  beforeMount() {
  }, // 生命周期 - 挂载之前
  beforeUpdate() {
  }, // 生命周期 - 更新之前
  updated() {
  }, // 生命周期 - 更新之后
  beforeDestroy() {
  }, // 生命周期 - 销毁之前
  destroyed() {
  }, // 生命周期 - 销毁完成
  activated() {
  }, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='scss' scoped>

</style>